package stu.day19_day24.day23;

import java.util.*;
import java.util.stream.Collectors;

public class hw2 {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int all_num = Integer.parseInt(sc.nextLine());
        for(int i=0;i<all_num;i++){
            int[] z = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            //System.out.println(z[1]);
            ArrayList<Integer> x = Arrays.stream(sc.nextLine().split(" ")).map(Integer::parseInt).sorted((o1, o2) -> o1-o2).collect(Collectors.toCollection(ArrayList::new));
            ArrayList<Integer> y = (ArrayList<Integer>)Arrays.stream(sc.nextLine().split(" ")).map(Integer::parseInt).sorted((o1, o2) -> o2-o1).collect(Collectors.toList());
            //System.out.println();
            //x.forEach(System.out::print);
            //System.out.println();
            //y.forEach(System.out::print);
            //System.out.println();
            System.out.println(test(z[1],x,y));

        }
    }



    public static boolean test(int num,List<Integer> x,List<Integer> y){


        Iterator<Integer> f1 = x.iterator();
        Iterator<Integer> f2 = y.iterator();

        while (f1.hasNext()&&f2.hasNext()){
            int xx = f1.next()+f2.next();
            if(xx<1||xx>num){
                return false;
            }
        }
        return true;

    }



}
